#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    char str[501][501];
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin >> str[i][j];

    unordered_map<char, int> hash = { {'l',4},{'o',3},{'v',2},{'e',1} };
    vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + hash[str[i][j]];
    cout << dp[n][m];
    return 0;
}